package com.hspedu.poly_.detail;

/**
 * @Author Stringzhua
 * @Date 2024/3/2 18:27
 * description:instanceof
 * 比较操作符,用于判断对象的运行类型是否为XX类型或XX类型的子类型
 */
public class PolyDetail03 {
    public static void main(String[] args) {
        BB bb = new BB();
        System.out.println(bb instanceof BB);//true
        System.out.println(bb instanceof AA);//true

        //aa的编译类型是AA 运行类型是BB
        AA aa=new BB();
        System.out.println(aa instanceof AA);//true
        System.out.println(aa instanceof BB);//true

        Object obj=new Object();
        System.out.println(obj instanceof AA);//false
        String str="zhuazhua";
//        System.out.println(str instanceof AA);
        System.out.println(str instanceof Object);//true
    }
}

class AA {//父类

}

class BB extends AA {//子类

}
